package com.jadobo.xswing.util;

import org.w3c.dom.Node;

import com.jadobo.xswing.attrib.HtmlElementTag;
import com.jadobo.xswing.model.Font;

public class Conv {

	public static java.awt.Font font(Font font) {
		
		// pre-condition check
		if(font == null) {
			return null;
		}
		
		int style = java.awt.Font.PLAIN;
		switch(font.getFontStyle()) {
		case italic:
			style = java.awt.Font.ITALIC;
			break;
		}
		
		return new java.awt.Font(font.getFont(), style, font.getSize()); 
	}
	
	public static HtmlElementTag elementTag(Node node) {
		
		HtmlElementTag tag = HtmlElementTag.UNKNOWN_OR_UNHANDLED;
		
		if(node != null) {
			String nodeName = node.getNodeName();
			try {
				tag = HtmlElementTag.valueOf(nodeName);
			} catch (Exception e) {
				
			}
		}
		
		return tag;
	}
}
